package com.ruoyi.web.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.web.domain.GuStock;
import com.ruoyi.web.service.IGuStockService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 股票行业板块Controller
 * 
 * @author ruoyi
 * @date 2025-07-31
 */
@RestController
@RequestMapping("/stock")
public class GuStockController extends BaseController
{
    @Autowired
    private IGuStockService guStockService;

    /**
     * 查询股票行业板块列表
     */
    @RequiresPermissions("system:stock:list")
    @GetMapping("/list")
    public TableDataInfo list(GuStock guStock)
    {
        startPage();
        List<GuStock> list = guStockService.selectGuStockList(guStock);
        return getDataTable(list);
    }

    /**
     * 导出股票行业板块列表
     */
    @RequiresPermissions("system:stock:export")
    @Log(title = "股票行业板块", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GuStock guStock)
    {
        List<GuStock> list = guStockService.selectGuStockList(guStock);
        ExcelUtil<GuStock> util = new ExcelUtil<GuStock>(GuStock.class);
        util.exportExcel(response, list, "股票行业板块数据");
    }

    /**
     * 获取股票行业板块详细信息
     */
    @RequiresPermissions("system:stock:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(guStockService.selectGuStockById(id));
    }

    /**
     * 新增股票行业板块
     */
    @RequiresPermissions("system:stock:add")
    @Log(title = "股票行业板块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GuStock guStock)
    {
        return toAjax(guStockService.insertGuStock(guStock));
    }

    /**
     * 修改股票行业板块
     */
    @RequiresPermissions("system:stock:edit")
    @Log(title = "股票行业板块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GuStock guStock)
    {
        return toAjax(guStockService.updateGuStock(guStock));
    }

    /**
     * 删除股票行业板块
     */
    @RequiresPermissions("system:stock:remove")
    @Log(title = "股票行业板块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(guStockService.deleteGuStockByIds(ids));
    }

    /**
     * 获取每日板块详细信息 --从 腾讯服务器
     */
    @GetMapping("/getTengxun")
    @RequiresPermissions("system:day:query")
    public AjaxResult getInfoFromTengXun()
    {
        return success(guStockService.getDataFromTengXun());
    }
}
